using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using User.Application.Contracts.Interfaces;
using User.Domain.Repositories;
using User.Infrastructure.Queries;
using User.Infrastructure.Repositories;

namespace User.Infrastructure
{
    public static class ServiceCollectionExtensions
    {
        public static IServiceCollection AddUserEfCore(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddDbContext<UserDbContext>(options =>
                options.UseNpgsql(configuration.GetConnectionString("Default")));

            services.AddScoped<IUserRepository, UserRepository>();
            services.AddScoped<IUserAppService, UserAppService>();
            
            services.AddScoped<IUnitOfWork, UnitOfWork>();
           
            return services;
        }
    }
}